import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();//地毯长度
        int [][] pot = new int[n][4];
        for (int i = 0; i <n ; i++) {
            for (int j = 0; j < 4; j++) {
                pot[i][j] = sc.nextInt();
            }
        }
        int x = sc.nextInt();//地面坐标
        int y = sc.nextInt();
        int num=-1;
        for (int i = 0; i <n ; i++) {
            if(x<=pot[i][0]+pot[i][2] &&x>=pot[i][0] && y<=pot[i][1]+pot[i][3] && y>=pot[i][1]){
                num=i+1;
            }
        }
        System.out.println(num);
    }
}
